<?php
require_once '../include/config.php';
require_once '../include/utils.class.php';
require_once '../include/orm.class.php';
$orm = new ORM();

try {
  $sql = "CREATE TABLE IF NOT EXISTS `pb_plugin` (
           `id` int NOT NULL AUTO_INCREMENT PRIMARY KEY,
           `folder` varchar(256) DEFAULT '' UNIQUE
          ) ENGINE=MYISAM;";
  $orm->exec($sql);
  
  $sql = "CREATE TABLE IF NOT EXISTS `pb_theme` (
           `id` int NOT NULL AUTO_INCREMENT PRIMARY KEY,
           `folder` varchar(256) DEFAULT '' UNIQUE
          ) ENGINE=MYISAM;";
  $orm->exec($sql);
  
  $sql = "CREATE TABLE IF NOT EXISTS `pb_plugin_instance` (
           `id` int NOT NULL AUTO_INCREMENT PRIMARY KEY,
           `page_id` int DEFAULT 0,
           `sys_id` int DEFAULT 0,
           `plugin_id` int DEFAULT 0,
           `name` varchar(256) DEFAULT '',
           `width` varchar(16) DEFAULT '',
           `height` varchar(16) DEFAULT ''
          ) ENGINE=MYISAM;";
  $orm->exec($sql);
  
  $sql = "CREATE TABLE IF NOT EXISTS `pb_sys` (
           `id` int NOT NULL AUTO_INCREMENT PRIMARY KEY,
           `name` varchar(256) DEFAULT '',
           `php_name` varchar(256) DEFAULT '' UNIQUE,
           `theme_id` int DEFAULT 0,
           `login_required` tinyint(1) DEFAULT 0,
           `login_id` int DEFAULT 0,
           `redmd` int DEFAULT 0,
           `ga_cd` varchar(64) DEFAULT '',
           `comp_bws` varchar(512) DEFAULT '',
           `description` text DEFAULT NULL,
           `keywords` text DEFAULT NULL
          ) ENGINE=MYISAM;";
  $orm->exec($sql);
  
  $sql = "CREATE TABLE IF NOT EXISTS `pb_page` (
           `id` int NOT NULL AUTO_INCREMENT PRIMARY KEY,
           `name` varchar(256) DEFAULT '',
           `sys_id` int DEFAULT 0,
           `parent_id` int DEFAULT 0,
           `order` double DEFAULT 0,
           `is_default` tinyint(1) DEFAULT 0,
           `is_visible` tinyint(1) DEFAULT 0,
           `html` text DEFAULT NULL,
           `css` text DEFAULT NULL,
           `js` text DEFAULT NULL,
           `icon` varchar(256) DEFAULT ''
          ) ENGINE=MYISAM;";
  $orm->exec($sql);
} catch (PDOException $e) {
  Utils::dump($e);
}
?>